package com.example.demo.Service;

import com.example.demo.Mappers.GetZyPatInfoMapper;
import com.example.demo.beans.GetZyPatInfoRequest;
import com.example.demo.beans.GetZyPatInfoResponse;
import com.example.demo.beans.ZYbrfyHjBean;
import com.example.demo.beans.ZyPatInfoBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by Administrator on 2018-05-23.
 */
@Service("GetZyPatInfoService")
public class GetZyPatInfoService {
    @Autowired
    private GetZyPatInfoMapper mapper;
    @Transactional(readOnly = true)
    public GetZyPatInfoResponse getZyInfo(GetZyPatInfoRequest request)
    {
        ZyPatInfoBean bean=mapper.getPatientInfo(request.getCardNo());
        GetZyPatInfoResponse response=new GetZyPatInfoResponse();
        if (bean!=null)
        {
            ZYbrfyHjBean ybrfyHjBean=mapper.getFyhj(bean.getZyno());


            Double yjje=Double.valueOf(ybrfyHjBean.getYJJ());
            Double zfy=Double.valueOf(ybrfyHjBean.getZFY());
            Double qf=yjje-zfy;
            String YE=String.valueOf(qf);

            response.setResultCode("0");
            response.setResultMsg("交易成功");

            response.setSex(bean.getSex());
            response.setAge(bean.getAge());
            response.setBedNo(bean.getBedNo());
            response.setDepName(bean.getDepName());
            response.setIsInpatient(bean.getIsInpatient());
            response.setName(bean.getName());
            response.setyE(YE);
            response.setyJJ(ybrfyHjBean.getYJJ());
            response.setzFY(ybrfyHjBean.getZFY());
            response.setZyDate(bean.getZyDate());
            response.setZyno(bean.getZyno());
return response;
        }
        else {response.setResultCode("0");
        response.setResultMsg("系统没有查询到相关序号的信息!");
        return  response;}

    }
}
